package com.wt.struggle.goodbye.user.adapter

import android.content.Context
import android.os.Bundle
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.Config
import com.wt.struggle.goodbye.base.ProBaseAdapter
import com.wt.struggle.goodbye.info.NewsInfo
import com.wt.struggle.goodbye.user.activity.MyPhotoActivity
import com.xin.lv.yang.utils.utils.ImageUtil
import kotlinx.android.synthetic.main.pic_delete_item.view.*

class PicDeleteAdapter(context: Context, list: ArrayList<NewsInfo>) : ProBaseAdapter<NewsInfo>(context, list) {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val vh = holder as VH
        val info = list[position]

        val w = (getW(context) - context.resources.getDimension(R.dimen.dp_20).toInt()) / 3
        vh.imagePic.layoutParams = RelativeLayout.LayoutParams(w, w)

        ImageUtil.getInstance()
            .loadRoundCircleImageBuyBitmap(context, vh.imagePic,
                Config.GET_IMAGE_URL + info.id,
                R.drawable.rc_grid_image_default, w,w,4)

        vh.imageChooseCheckBox.visibility = View.VISIBLE

        vh.imageChooseCheckBox.setOnCheckedChangeListener { compoundButton, b ->

            (context as MyPhotoActivity).addChoose(info, b)

        }

    }


    override fun onCreateView(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return VH(inflater.inflate(R.layout.pic_delete_item, parent, false))
    }

    override fun onUpdateHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: MutableList<Any>) {

    }

    inner class VH(view: View) : RecyclerView.ViewHolder(view) {
        val imagePic = view.imagePic
        val imageChooseCheckBox = view.imageChooseCheckBox

    }
}